//
//  DDinterviewHeaderView.swift
//  DingDongZP
//
//  Created by 三秒文化 on 2016/10/25.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

import UIKit

class DDinterviewHeaderView: UIView {
    
    private let title = "叮咚快聘 - 面试邀请"
    private var name = ""
    
    
    private var titleLab = { return UILabel.setBaseLab("叮咚快聘 － 面试邀请", fontSize: 16, titleColor: LDFontColor.White, Alignment: .Left) }()
    private var nameLab = { return UILabel.setBaseLab("叮咚快聘 － 面试邀请", fontSize: 11, titleColor: LDFontColor.White, Alignment: .Left) }()
    private var imgMailV = { return  UIImageView(image: UIImage(named: "common_interview_back_mail")) }()
    private var backImgV = { return  UIImageView(image: UIImage(named: "common_interview_back")) }()
    
    dynamic var nameTitle:String?
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        initUI()
        
        layoutUI()
    }
    
    //
    func initUI() {
        
        
        backgroundColor = LDGolbalColor.BgGoundGray
        nameLab.numberOfLines = 0
        addSubview(backImgV)
        addSubview(imgMailV)
        addSubview(titleLab)
        addSubview(nameLab)
        
        
        RACObserve(self, "nameTitle").subscribeNext { [weak self] (obj) in
            
            let strname = String(format: "亲爱的 %@，感谢您对我们公司的信任，现诚邀您来参加面试", self?.nameTitle ?? "")
            self?.nameLab.text = strname
        }
        
    }
    
    func layoutUI() {
        
        backImgV.snp_makeConstraints { (make) in
            
            make.top.equalTo(LDMargin_V*2)
            make.bottom.equalTo(-LDMargin_V)
            make.left.right.equalTo(0)
        }
        
        imgMailV.snp_makeConstraints { (make) in
            
            make.centerY.equalTo(backImgV)
            make.left.equalTo(LDMargin_V*4)
            make.size.equalTo(CGSizeMake(40, 35))
        }
        
        titleLab.snp_makeConstraints { (make) in
            
            make.left.equalTo(imgMailV.snp_right).offset(35)
            make.bottom.equalTo(backImgV.snp_centerY).offset(-LDMargin_V)
            make.height.equalTo(16)
        }
        
        nameLab.snp_makeConstraints { (make) in
            
            make.top.equalTo(backImgV.snp_centerY).offset(LDMargin_V)
            make.left.equalTo(titleLab)
            make.right.equalTo(-5)
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
